package com.bsoft.gol.hbs.dao;

import ctd.persistence.annotation.DAOMethod;
import ctd.persistence.annotation.DAOParam;
import hcn.base.BaseTransferPlatform;
import hcn.base.drug.vo.BaseTransferVo;
import org.atag.dao.util.BaseDaoImpl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by pangxl on 2019/12/19.
 */
public abstract class BaseTransferPlatformDAO extends BaseDaoImpl<BaseTransferPlatform> {
    public BaseTransferPlatformDAO() {
        this.setKeyField("platformId");
    }

    @DAOMethod(sql = " from BaseTransferPlatform where platform_url=:platformUrl ")
    public abstract BaseTransferPlatform getBaseTransferPlatform(@DAOParam("platformUrl") String platformUrl);


    public List<BaseTransferVo> queryBaseTransfePlatformrList(final String orgId) {
        Map<String, Object> params = new HashMap<>();
        StringBuffer hsql = new StringBuffer();
        hsql.append("SELECT r.platform_id AS platformId, r.platform_name AS platformName, p.platform_url AS platformUrl, r.status, r.transfer_type AS transferType, r.relation_id AS relationId, r.create_dt AS createDt, r.create_user AS createUser, r.enable_dt AS enableDt, r.enable_user AS enableUser, r.modify_dt AS modifyDt, r.modify_user AS modifyUser, r.delete_flag AS deleteFlag ");
        hsql.append(" from base_transfer_relation r");
        hsql.append(" LEFT JOIN base_transfer_platform p ON p.platform_id = r.platform_id");
        hsql.append(" where r.org_id=:orgId");
        params.put("orgId", orgId);
        return super.findListBySql(hsql.toString(), params, BaseTransferVo.class);
    }

}
